package com.fjrcloud.controller;

import com.fjrcloud.service.ProjectService;
import com.fjrcloud.entity.ProjectGroup;
import com.fjrcloud.entity.ResponseBean;
import com.fjrcloud.entity.ResponseFactory;
import com.fjrcloud.exception.BusinessException;
import com.fjrcloud.utils.StatusUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by shengjian.lin on 17-5-6.
 */
@Controller
@RequestMapping("api/project")
public class ProjectController {
    @Autowired
    private ProjectService service;

    @RequestMapping("get")
    @ResponseBody
    public ResponseBean get(Integer id) throws BusinessException {
        return ResponseFactory.getResponseBean(StatusUtils.Success,service.get(id));
    }
    @RequestMapping("del")
    @ResponseBody
    public ResponseBean del(Integer id) throws BusinessException {
        service.del(id);
        return ResponseFactory.getResponseBean(StatusUtils.Success);
    }
    @RequestMapping("list")
    @ResponseBody
    public ResponseBean list() throws BusinessException {
        return ResponseFactory.getResponseBean(StatusUtils.Success,service.list(null,null));
    }
    @RequestMapping("save")
    @ResponseBody
    public ResponseBean save(ProjectGroup group) throws BusinessException {
        return ResponseFactory.getResponseBean(StatusUtils.Success,service.save(group));
    }
}
